/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
/*
 * {{get_generation_time()}}
 * {{get_project_name()}}
 * {{get_vcos_version()}}
 * Description:  MemIf 配置源文件.
*/

#include "memif_types.h"
#include "memif_cfg.h"
{%- if Memif_General["MemIfGeneral"]["MemIfUseFlashStore"]["Value"] == true %}
#include "Fee.h"
{%- elif Memif_General["MemIfGeneral"]["MemIfUseEepromStore"]["Value"] == true %}
extern void ea_set_mode(uint8 mode);
extern uint8 ea_read_block(uint16 block_number, uint16 block_offset, uint8 *data_buffer_ptr, uint16 length);
extern uint8 ea_write_block(uint16 block_number, const uint8 *data_buffer_ptr);
extern void ea_cancel(void);
extern uint8 ea_get_status(void);
extern uint8 ea_get_job_result(void);
extern uint8 ea_invalidate_block(uint16 block_number);
extern uint8 ea_erase_immediate_block(uint16 block_number);
{%- endif %}

#define  MEMIF_START_SEC_CONST
#include "memif_memmap.h"
CONST(memif_abs_api_type, MEMIF_CONST) memif_hw_abstraction[MEMIF_NUMBER_OF_DEVICES] =
{
{%- if Memif_General["MemIfGeneral"]["MemIfUseFlashStore"]["Value"] == true %}
   /*  Fee  */ {
    Fee_Read,
    Fee_Write,
    Fee_EraseImmediateBlock,
    Fee_InvalidateBlock,
    Fee_Cancel,
    Fee_GetStatus,
    Fee_GetJobResult,
    Fee_SetMode
  }
{%- elif Memif_General["MemIfGeneral"]["MemIfUseEepromStore"]["Value"] == true %}
   /*  ea  */ {
    ea_read_block,
    ea_write_block,
    ea_erase_immediate_block,
    ea_invalidate_block,
    ea_cancel,
    ea_get_status,
    ea_get_job_result,
    ea_set_mode
  }
{%- else %}
   /*  not support  */ {
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
  }
{%- endif %}
};
#define  MEMIF_STOP_SEC_CONST
#include "memif_memmap.h"

